<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>Compras</title>
            <link rel="stylesheet" type="text/css" href="/globalimage2/faces/jsfcrud.css" /><%@ include file="/WEB-INF/jspf/AjaxScripts.jspf" %><script type="text/javascript" src="/globalimage2/faces/jsfcrud.js"></script>
        </head>
        <body>
            <%@include file="../../WEB-INF/jspf/header/head.jspf"%>
            <div style="float:left">
                <%@include file="../../WEB-INF/jspf/header/menuDinamico.jspf"%>
            </div>
            <div id="div_content">
                <div class="bgContentTable">
                    <div class="titleTable"><h3>Compras</h3></div><br />

                    <h:form styleClass="jsfcrud_list_form">
                        <h:commandLink action="#{compra.createSetup}" value="Novo"/>

                        <h:panelGroup id="messagePanel" layout="block">
                            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                        </h:panelGroup>
                        <h3>Compras</h3>
                        <h:outputText escape="false" value="Não foi encontrado registros<br />" rendered="#{compra.pagingInfo.itemCount == 0}" />
                        <h:panelGroup rendered="#{compra.pagingInfo.itemCount > 0}">
                            <h:outputText value="Item #{compra.pagingInfo.firstItem + 1}..#{compra.pagingInfo.lastItem} de #{compra.pagingInfo.itemCount}"/>&nbsp;
                            <h:commandLink action="#{compra.prev}" value="Anterior #{compra.pagingInfo.batchSize}" rendered="#{compra.pagingInfo.firstItem >= compra.pagingInfo.batchSize}"/>&nbsp;
                            <h:commandLink action="#{compra.next}" value="Próximo #{compra.pagingInfo.batchSize}" rendered="#{compra.pagingInfo.lastItem + compra.pagingInfo.batchSize <= compra.pagingInfo.itemCount}"/>&nbsp;
                            <h:commandLink action="#{compra.next}" value="Restantes #{compra.pagingInfo.itemCount - compra.pagingInfo.lastItem}"
                                           rendered="#{compra.pagingInfo.lastItem < compra.pagingInfo.itemCount && compra.pagingInfo.lastItem + compra.pagingInfo.batchSize > compra.pagingInfo.itemCount}"/>
                                           <h:dataTable value="#{compra.compraItems}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Observacao"/>
                                    </f:facet>
                                    <h:outputText value=" #{item.observacao}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Data compra"/>
                                    </f:facet>
                                    <h:outputText value="#{item.dataCompra}">
                                        <f:convertDateTime pattern="dd/ MM/ yyyy" />
                                    </h:outputText>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Funcionario"/>
                                    </f:facet>
                                    <h:outputText value=" #{item.funcionarioId}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Vendedor"/>
                                    </f:facet>
                                    <h:outputText value=" #{item.vendedorId}"/>
                                </h:column>
                                 <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Empresa"/>
                                    </f:facet>
                                    <h:outputText value=" #{item.vendedorId.empresaId.nome}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText escape="false" value="&nbsp;"/>
                                    </f:facet>
                                    <h:commandLink value="Exibir" action="#{compra.detailSetup}">
                                        <f:param name="jsfcrud.currentCompra" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][item][compra.converter].jsfcrud_invoke}"/>
                                    </h:commandLink>
                                </h:column>
                            </h:dataTable>
                        </h:panelGroup>
                    </h:form>
                </div>
            </div>
        </body>
    </html>
</f:view>
